package com.frostmourne.mxsattributeinventory.listeners;

import com.frostmourne.mxsattributeinventory.hooks.DAHook;
import com.frostmourne.mxsattributeinventory.utils.MsgUtils;
import eos.moe.armourers.api.DragonAPI;
import eos.moe.armourers.api.PlayerSkinUpdateEvent;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;

import java.util.ArrayList;
import java.util.List;

public class ExpandListener implements Listener {

    @EventHandler
    public void updateArmourers(PlayerSkinUpdateEvent e){
        Player player = e.getPlayer();
        if (DAHook.playerArmourersMap.containsKey(player)){
            List<String> skins = new ArrayList<>();
            for (String invName : DAHook.playerArmourersMap.get(player).keySet()){
                List<ItemStack> items = DAHook.playerArmourersMap.get(player).get(invName);
                for (ItemStack item : items){
                    String skinName = DragonAPI.getItemSkinName(item);
                    if (skinName != null){
                        skins.add(skinName);
                    }
                }
            }
            e.setSkinList(skins);
        }
    }

}
